﻿/*
 * Coordinate
 * 
 * initial implementation : 29.8.2007
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
using System.Globalization;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Petra.Gis.Geometry;


namespace Petra.Gis.Geometry.Support
{
  /// <summary>
  /// Coordinate - general purpose point with 3d support.
  /// Coordinate supports access to coordinate value pair (triplet) in 2 ways
  /// either by X,Y or lon,lat properties. Both has same meaning, just syntactic sugar
  /// Coordinate is readwrite.
  /// </summary>
  public partial class Coordinate : ICoordinate
  {
    //each inherited class must have own storage for ordinates
    private double dX, dY, dZ;


    
    public Coordinate(double x, double y, double z)
    {
      dX = x;
      dY = y;
      dZ = z;
    }



    
    
    
    public Coordinate(double x, double y)
      : this(x, y, 0)
    { }
    
    


    
    public Coordinate()
      :this(0,0,0)
    {}





    public virtual double X { get { return dX; } set { dX = value; } }
    public virtual double Y { get { return dY; } set { dY = value; } }
    public virtual double Z { get { return dZ; } set { dZ = value; } }



    public virtual double lon { get { return dX; } set { dX = value; } }
    public virtual double lat { get { return dY; } set { dY = value; } }




    /// <summary>
    /// compare this coordinate values to another in desired dimension
    /// </summary>
    /// <param name="AnotherPoint">another coordinate to compare to</param>
    /// <param name="dimension">compare dimension</param>
    /// <returns>true when coordinate values are same in given dimension, false otherwise</returns>
    public bool Equals(ICoordinate AnotherPoint, Dimension dimension)
    {
      bool isSame = false;
      if (this.X == AnotherPoint.X && this.Y == AnotherPoint.Y)
        isSame = true;
      if (dimension == Dimension.dim3D && (this.Z != AnotherPoint.Z))
        isSame = false;
      return isSame;
    }


  }

}
